// ~~~上传头像的JS
layui.use(function () {
    var upload = layui.upload;
    var layer = layui.layer;
    var element = layui.element;
    var $ = layui.$;
    // 单图片上传
    var uploadInst = upload.render({
        elem: '#ID-upload-demo-btn',
        accept:'file',
        url: serverConfig.serverUrl + '/devs/avatar', // 实际使用时改成您自己的上传接口即可。
        before: function () {
            element.progress('filter-demo', '0%'); // 进度条复位
            layer.msg('上传中', {icon: 16, time: 0});
        },
        done: function (res) {
            // 若上传失败
            if (res.code == 500) {
                $('#ID-upload-demo-text').html('');
                return layer.msg('上传失败');
            }else if (res.code==200){
                $('#ID-upload-demo-img').attr('src', `http://${res.data.imageUrl[0]}`);
                return layer.msg('上传成功')
            }
            $('#ID-upload-demo-text').html(''); // 置空上传失败的状态
        },
        error: function () {
            // 演示失败状态，并实现重传
            var demoText = $('#ID-upload-demo-text');
            demoText.html('<span style="with: 100px; color: indianred; font-size: 17px; margin-left: 75px; display: block; float: left;">上传失败</span> <a class="layui-btn layui-btn-primary layui-btn-xs demo-reload" style="margin-left:2px;">重试</a>');
            demoText.find('.demo-reload').on('click', function () {
                uploadInst.upload();
            });
        },
    });
});

// ~~~生日的JS
layui.use(function () {
    var laydate = layui.laydate;
    // 渲染
    laydate.render({
        elem: '#ID-laydate-demo'
    });
    // 英文版
    laydate.render({
        elem: '#ID-laydate-demo-en',
        lang: 'en'
    });
});
//~~~~~查询个人信息
